// pages/detial/detial.js
Page({

  /**
   * 页面的初始数据
   */
  data: {

    guest: {
      name: '李佳琪',
      idcard:'452402200003042311',
      date:'2022/03/04',
      phone: '18978455555',
      volnumber:'1111111',
      birthday:'2001/05/18'
    

    },

    politics:['中共党员','中共预备党员','共青团员','群众'],
    politics_value: '0',

    certificates:['居民身份证','港澳通行证','护照','士官证'],
    certificates_value:'0',

    gender:['男','女'],
    gender_value:'0',

  },
  
  //证件类型
  bindPickerCertificatesChange(e) {
    this.setData({
      certificates_value: e.detail.value,
    }); 
  },

  //idcard失去监听
  idcardChange:function (e) {
    this.setData({
      idcard_focus: false
    })
    // 校验身份证
    var idcard = e.detail.value;
    this.checkIdcard(idcard);
  },
  //用正则表达式校验身份证
  checkIdcard:function(idcard) {
    var reg = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
    return this.check(reg, idcard, '输入的身份证号码有误');
  },

  //政治面貌
  bindPickerPoliticsChange(e) {
    this.setData({
      politics_value: e.detail.value,
    }); 
  },
    //性别
    bindPickerGenderChange(e) {
      this.setData({
        gender_value: e.detail.value,
      }); 
    },

  // phone输入框失去焦点监听
  phoneChange: function (e) {
    this.setData({
      phone_focus: false
    })
    // 校验电话
    var phone = e.detail.value;
    this.checkPhone(phone);
  },

  // 用正则表达式校验电话
  checkPhone: function (phone) {
    var reg = /^(((13)|(15)|(17)|(18))\d{9})$/;
    return this.check(reg, phone, '输入的电话有误');
  },

})
